import {createSlice} from "@reduxjs/toolkit";
import {getChannelApi} from "@/apis/article";

const articleStore=createSlice({
    name:'article',
    initialState:{
        channelList:[]
    },
    reducers:{
        setChannelList(state,action){
            state.channelList=action.payload
        }
    }
})

const {setChannelList}=articleStore.actions

const getChannelList=()=>{
    return async (dispatch)=>{
        const res=await getChannelApi()
        dispatch(setChannelList(res.data.channels))
    }
}


export {getChannelList}
const articleReducer=articleStore.reducer
export default articleReducer
